<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../../infrastructure/test.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
  ">
  <creator>
    <name>Herm Fischer</name>
    <email>fischer@markv.com</email>
  </creator>

  <number>90502</number>

  <name>xfi:navigate-relationships</name>

  <description>
    Tests navigation function.
  </description>

  <variation id="V-01">
    <name>Children of def-test arcrole in link role link1</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-child-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-child-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-child-result.xml</instance>
    </result>
  </variation>

  <variation id="V-02">
    <name>Descendants to 2 levels of def-test arcrole in link role link1</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-2child-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-2child-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-2child-result.xml</instance>
    </result>
  </variation>

  <variation id="V-03">
    <name>Children or self of def-test arcrole in link role link1</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-child-or-self-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-child-or-self-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-child-or-self-result.xml</instance>
    </result>
  </variation>

  <variation id="V-04">
    <name>Parents of def-test arcrole in link role link1</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-parent-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-parent-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-parent-result.xml</instance>
    </result>
  </variation>

  <variation id="V-05">
    <name>Sibling of def-test arcrole in link role link1</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-sibling-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-sibling-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-sibling-result.xml</instance>
    </result>
  </variation>

  <variation id="V-06">
    <name>Sibling or self of presentation arcrole in link role link2</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-sibling-or-self-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-sibling-or-self-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-sibling-or-self-result.xml</instance>
    </result>
  </variation>

  <variation id="V-07">
    <name>Roots presentation arcrole in link role link2</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-roots-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-roots-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-roots-result.xml</instance>
    </result>
  </variation>

  <variation id="V-08">
    <name>Roots and descendants presentation arcrole in link role link2</name>
    <description>
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-test-roots2-formula.xml</linkbase>
      <instance readMeFirst="true">nav-test-roots2-instance.xml</instance>
    </data>
    <result>
      <instance>nav-test-roots2-result.xml</instance>
    </result>
  </variation>


  <variation id="V-20">
    <name>Calculation linkbase validation, exact, no inconsistency</name>
    <description>
       Calculation relations with their PSVI-typed weight attribute are used to filter parent and family members (all fact values matching parent in aspects such as period, etc) to produce a generalVariable, weightedChildValues, which is a sequence of those family members whose QNames are 1-level calc linkbase descendants, mulitplied by the PSVI-typed weight attribute.  Precondition blocks firing if no children (e.g., parent is a tree leaf).  The value assertion is exact (no rounding considering decimals attribute).  Formatted messages are available to produce human-readable assertion results.
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-exact-sum-weighted-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-exact-sum-weighted-children-instance-ok.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="6"
         countNotSatisfied="0" />      
    </result>
  </variation>

  <variation id="V-21">
    <name>Calculation linkbase validation, exact, one inconsistency</name>
    <description>
       Same as V-20, but one inconsistent fact item is introduced, causing two calculation assertions to be unsuccessful.  There are two inconsistencies because the inconsistent fact is both a sum (having children) and contributor to its parent.
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-exact-sum-weighted-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-exact-sum-weighted-children-instance-ok.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="4"
         countNotSatisfied="2" />      
    </result>
  </variation>

  <variation id="V-22">
    <name>Calculation linkbase validation, decimals rounding, no inconsistency</name>
    <description>
       The decimals attribute is processed for rounding.  Calculation relations with their PSVI-typed weight and fact decimal attributes are used to filter parent and family members (all fact values matching parent in aspects such as period, etc) to produce a generalVariable, weightedChildValues, which is a sequence of those family members whose QNames are 1-level calc linkbase descendants, mulitplied by the PSVI-typed weight attribute, and rounded by the fact item PSVI-typed decimals attribute.  Precondition blocks firing if no children (e.g., parent is a tree leaf).  The value assertion is exact (no rounding considering decimals attribute).  Formatted messages are available to produce human-readable assertion results. Important note: the round-half-to-even function requires xfi:decimals (inferred or as reported) for the attribute that it calls 'precision', even if the fact is reported as @precision.  (An additional if () would be required to process 'INF' decimals values.)
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-sum-weighted-rounded-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-sum-weighted-rounded-children-instance-ok.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="6"
         countNotSatisfied="0" />      
    </result>
  </variation>


  <variation id="V-23">
    <name>Calculation linkbase validation, decimals rounding, one inconsistency</name>
    <description>
       Same as V-22, but one inconsistent fact item is introduced, causing two calculation assertions to be unsuccessful.  There are two inconsistencies because the inconsistent fact is both a sum (having children) and contributor to its parent.
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-sum-weighted-rounded-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-sum-weighted-rounded-children-instance-err1.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="4"
         countNotSatisfied="2" />      
    </result>
  </variation>


  <variation id="V-24">
    <name>Calculation linkbase validation, threshold test, no inconsistency</name>
    <description>
       A threshold-based test is used. As with V-20, the sum of weighted children and parent are compared, but within absolute value of threshold.  If above threshold an error is reported. 
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-threshold-sum-weighted-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-threshold-sum-weighted-children-instance-ok.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="6"
         countNotSatisfied="0" />      
    </result>
  </variation>


  <variation id="V-25">
    <name>Calculation linkbase validation, decimals rounding, one inconsistency</name>
    <description>
       Same as V-22, but two inconsistent fact item is introduced, causing one calculation assertions to be unsuccessful.  There is only one inconsistency because the inconsistent facts are leaf nodes that contribute only to their parent (unlike V-21 and V-23 where the inconsistencies are intermediate nodes, not leaf nodes).
     </description>
      
    <data>
      <schema>nav-rel-test1.xsd.xsd"</schema>
      <linkbase>nav-rel-test1-detached-calculation.xml</linkbase>
      <linkbase>calc-lb-threshold-sum-weighted-children-formula.xml</linkbase>
      <instance readMeFirst="true">calc-lb-threshold-sum-weighted-children-instance-err1.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="calc-linkbase-assertion"
         countSatisfied="5"
         countNotSatisfied="1" />      
    </result>
  </variation>


  <variation id="V-30">
    <name>Movement pattern by Charlie Hoffman</name>
    <description>
     </description>
      Automates a movement pattern.  Presentation tree has movement subtrees each with beginning balance, subtree of changes, and ending balance.  Assertion's variables are:  (1) general variable $movementParent binds to each movement subtree parent; (2) general variable $movementItems binds to sequence of all QNames that are descendants of pattern subtree (e.g., all balances and changes); (3) fact variable $changes binds to all descendants that are duration items, subpartitioning by dates; (4) fact variable $endingBalance binds to descendant items that are instant matching end of subpartitioned duration; (5) fact variable $startingBalance binds to descendant itmes that are instant matching beginning of subpartitioned duration; (6) assertion is fired.
    <data>
      <schema>MovementsAnalysis.xsd"</schema>
      <linkbase>MovementsAnalysis-formula.xml</linkbase>
      <instance readMeFirst="true">MovementsAnalysis-instance.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="movement-assertion"
         countSatisfied="4"
         countNotSatisfied="0" />      
    </result>
  </variation>

  <variation id="V-31">
    <name>Movement pattern with error</name>
    <description>
     </description>
      Same as V-20 but with one error.
    <data>
      <schema>MovementsAnalysis.xsd"</schema>
      <linkbase>MovementsAnalysis-formula.xml</linkbase>
      <instance readMeFirst="true">MovementsAnalysis2-instance.xml</instance>
    </data>
    <result>
      <assertionTests 
         assertionID="movement-assertion"
         countSatisfied="3"
         countNotSatisfied="1" />      
    </result>
  </variation>

</testcase>


